//
//  AboutProducController.m
//  KMedicine
//
//  Created by 曹牧 on 16/7/5.
//  Copyright © 2016年 caomu. All rights reserved.
//


#import "AboutProducController.h"
#import "WJProtocolView.h"

@interface AboutProducController ()
@property(nonatomic,weak)UIImageView *logoImageView;
@property(nonatomic,weak)UIImageView *textImageView;
@property(nonatomic,weak)UILabel *titleLabel;
@property(nonatomic,weak)UILabel *versionLabel;
@property(nonatomic,weak)WJProtocolView *userProView;
@property(nonatomic,weak)UIView *lineView;
@end

@implementation AboutProducController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupUI];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];

}

- (void)setupUI{
    

    //创建一个logoImageView
    UIImageView *logoImageView = [[UIImageView alloc]init];
    self.logoImageView = logoImageView;
    logoImageView.image = [UIImage imageNamed:@"product_img_logo_nor.png"];
    [logoImageView sizeToFit];
    [self.view addSubview:logoImageView];
    
    //创建一个textImageView
    UIImageView *textImageView = [[UIImageView alloc]init];
    self.textImageView = textImageView;
    textImageView.image = [UIImage imageNamed:@"product_text_logo_nor.png"];
    [textImageView sizeToFit];
    [self.view addSubview:textImageView];
    
    //用户交流群
    UILabel *titleLabel = [[UILabel alloc]init];
    self.titleLabel = titleLabel;
    titleLabel.text =@"用户交流群: 4638375473";
    titleLabel.textAlignment = NSTextAlignmentCenter;
    NSDictionary *dic = @{NSFontAttributeName:[UIFont fontWithName:@"Heiti SC" size:20],NSForegroundColorAttributeName:[UIColor blueColor]};
    NSAttributedString *attriStr = [[NSAttributedString alloc]initWithString:titleLabel.text attributes:dic];
    [titleLabel setAttributedText:attriStr];
    [self.view addSubview:titleLabel];
    [self setconstraint];
    
    //用户交流群
    UILabel *versionLabel = [[UILabel alloc]init];
    self.versionLabel = versionLabel;
    versionLabel.text =@"version: 1.4.0";
    versionLabel.textAlignment = NSTextAlignmentCenter;
    NSDictionary *dicVer = @{NSFontAttributeName:[UIFont fontWithName:@"Heiti SC" size:20],NSForegroundColorAttributeName:[UIColor blueColor]};
    NSAttributedString *attriStrVer = [[NSAttributedString alloc]initWithString:versionLabel.text attributes:dicVer];
    [versionLabel setAttributedText:attriStrVer];
    [self.view addSubview:versionLabel];
    
    //用户协议
    WJProtocolView *userProView = [[WJProtocolView alloc]init];
    self.userProView = userProView;
    [self.view addSubview:userProView.view];
    [self addChildViewController:userProView];
    
//    //----分割线----
    UIView *lineView = [[UIView alloc]init];
    self.lineView = lineView;
    lineView.backgroundColor = [UIColor grayColor];
    [self.view addSubview:lineView];
    
    //约束方法
    [self setconstraint];
    
    
   
    
}

- (void)setconstraint{
    //logoImageView
    [self.logoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        //距离导航栏的距离
        make.top.equalTo(self.mas_topLayoutGuideBottom).offset(38);
        make.centerX.mas_equalTo(self.view.center.x).offset(0);
        
    }];
    
    //textImageView
    [self.textImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.logoImageView.mas_bottom).offset(0);
        make.centerX.mas_equalTo(self.textImageView.center.x).offset(0);
    }];
    
    //用户交流群
    [self.titleLabel makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.equalTo(self.view).offset(-80);
        make.leading.equalTo(self.view).offset(0);
        make.trailing.equalTo(self.view).offset(0);
    }];
    
    //Version
    [self.versionLabel makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(0);
        make.leading.equalTo(self.view).offset(0);
        make.trailing.equalTo(self.view).offset(0);
    }];
    
    //用户协议
    [self.userProView.view makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.textImageView.mas_bottom).offset(50);
        make.leading.equalTo(self.view).offset(0);
        make.trailing.equalTo(self.view).offset(0);
        make.height.equalTo(32);
        
    }];
    

    
//    ----分割线----
    [self.lineView makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.userProView.view.bottom).offset(0);
        make.leading.equalTo(self.view).offset(45);
        make.trailing.equalTo(self.view).offset(0);
        make.height.equalTo(1);
    }];
    
}

@end
